﻿using System;
using System.Collections.Concurrent;
using Wireframe;

namespace SampleWebCrawler
{
    public sealed class UriDatabase
    {
        private readonly ConcurrentDictionary<string, DateTime> _visits = new ConcurrentDictionary<string, DateTime>();

        public void HandleNewUriEvent(NewUriEvent message)
        {
            if (_visits.TryAdd(message.Value, DateTime.UtcNow))
            {
                this.Send(new LoadHtmlEvent(message.Value));
            }
        }
    }
}